
package com.idealighter.game.games.wknh.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.wknh.WknhPlayer;
import com.idealighter.game.games.wknh.message.ReqScenceMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@ResMsgHandler(523212)
public class ResEnterTableHandler implements ResMessageHandler {

  private static final Logger LOG = LoggerFactory.getLogger(ResEnterTableHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    // ResEnterTableMsg msg = (ResEnterTableMsg)message;
    LOG.info("[悟空闹海]玩家[{}][{}]进入悟空闹海桌子[{}]成功", player.userName, player.playerId,
        player.table(player.playerId).getId());
    WknhPlayer wknhPlayer = (WknhPlayer) player;

    // 延时5秒请求场景数据
    wknhPlayer.schedule(() -> {
      wknhPlayer.sendMsg(new ReqScenceMsg());
    }, RandCodeUtil.random(5, 8), TimeUnit.SECONDS);
  }
}
